package sc.export
{
	import flash.events.Event;
	import sc.*;
	import flash.events.Event;
	import flash.filesystem.*;
	public class FilesystemExport extends BaseExport
	{
		public function FilesystemExport()
		{
			super();
		}
		
		public function publishAsHtmlDir(exten:String, rootPath:String):void {
			ext = exten;
			path = rootPath;
			
			var fileChooser:File;
				if (currentFile)
				{
					fileChooser = currentFile;
				}
				else
				{
					fileChooser = defaultDirectory;
				}
				fileChooser.browseForDirectory("Choose the directory for your site...");
				
				fileChooser.addEventListener(Event.SELECT, saveDirOfHtmlHandler);
			
		}
		
		public function saveDirOfHtmlHandler(event:Event):void 
		{
				currentFile = event.target as File;
				currentFile.removeEventListener(Event.SELECT, saveDirOfHtmlHandler);
				saveDirOfHtml(currentFile);
				$.main.ws.selectedIndex = 0;		
		}
		
		public function publishAsSingleHtml(rootPath:String):void 
		{
			//ext = exten;
			path = rootPath;
			var fileChooser:File;
				if (currentFile)
				{
					fileChooser = currentFile;
				}
				else
				{
					fileChooser = defaultDirectory;
				}
				fileChooser.browseForSave("Save...");
				
				fileChooser.addEventListener(Event.SELECT, saveSingleHtmlHandler);
		}
		
		public function saveSingleHtmlHandler(event:Event):void 
		{
				currentFile = event.target as File;
				currentFile.removeEventListener(Event.SELECT, saveSingleHtmlHandler);
				saveSingleHtml(currentFile);
				$.main.ws.selectedIndex = 0;		
		}
		
		public function publishAsZip(rootPath:String):void 
		{
			//ext = exten;
			path = rootPath;
			var fileChooser:File;
				if (currentFile)
				{
					fileChooser = currentFile;
				}
				else
				{
					fileChooser = defaultDirectory;
				}
				fileChooser.browseForSave("Save...");
				
				fileChooser.addEventListener(Event.SELECT, saveZipOfHtmlHandler);
		} 
		
		public function saveZipOfHtmlHandler(event:Event):void 
		{
				currentFile = event.target as File;
				currentFile.removeEventListener(Event.SELECT, saveZipOfHtmlHandler);
				saveZipOfHtml(currentFile);
				$.main.ws.selectedIndex = 0;		
		}
		
	}
}